package server

import (
	"gitee.com/llakcs/agile-go/transport"
	"gitee.com/llakcs/agile-go/transport/grpc"
	"gitee.com/llakcs/aglie-layout/api"
	"gitee.com/llakcs/aglie-layout/api/pb"
	"gitee.com/llakcs/aglie-layout/conf"
)

func NewGrpcServer(conf *conf.GrpcConf) transport.Server {
	var opts = []grpc.ServerOption{
		grpc.Address(conf.Addr),
	}
	if conf.Timeout != 0 {
		opts = append(opts, grpc.Timeout(conf.Timeout))
	}
	s := grpc.NewServer(opts...)
	pb.RegisterUserInfoServiceServer(s, &api.UserServer{})
	return s
}
